<?php 

 header("Content-type: text/html; charset=utf-8");
require("conn.php");

$data = $_POST['data'];
$data=json_decode($data,true);



$user = end($data);
$dindan = array_pop($data);
$sql22 = '';
for ($i= 0; $i <count($data); $i++) {

	$singer = $data[$i];
	$slq11 = "select * from pin where id ='".$singer['pinid']."'  ";
	$result = mysql_query($slq11 ,$conn);
	$row = mysql_fetch_array($result );
		
	$huokuan = $singer['shu'] * $row['jia'];
	$hao = time();
$sql22.= " ('".$singer['pinid']."','".$user['id']."',0,'".$hao."','".$singer['shu']."','".$huokuan."'),";

}
$sql22 = substr($sql22,0,strlen($sql22)-1);
$sql22 ="INSERT INTO dingdan (pid,uid,fahuo,hao,shu,huokuan) VALUES ".$sql22.';';

$result11 = mysql_query($sql22);

if ($result11) {
	echo 1;
}